#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H

#include "term.h"
#include <vector>

class Polynomial
{
public:
    Polynomial();
    Polynomial(int coeff);
    Polynomial(const Term &t);
    Polynomial(const std::string &str);
    Polynomial(const Polynomial &p);
    Polynomial &operator=(const Polynomial &p);
    friend std::ostream &operator<<(std::ostream &out, const Polynomial &p);
    friend std::istream &operator>>(std::istream &in, Polynomial &);
    friend Polynomial operator+(const Polynomial &p, const Term &t);
    friend Polynomial operator+(const Polynomial &p1, const Polynomial &p2);
    Polynomial &operator+=(const Polynomial &p);
    friend Polynomial operator*(const Polynomial &p, const Term &t);
    friend Polynomial operator*(const Polynomial &p1, const Polynomial &p2);
    Polynomial &operator*=(const Polynomial &p);

private:
    std::vector<Term> poly;
    int degree;
    void sortTerms();
};

#endif // POLYNOMIAL_H
